﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DomainModel;
using Utils;

namespace WebUI.Models
{
    public class IndEditProfileViewModel: BaseViewModel
    {
        public IndEditProfileViewModel()
            : base()
        { }

        public Login Login { get; set; }
        public Ind Ind { get; set; }

        public HttpPostedFileBase Avatar { get; set; }
        public string AvatarUrl { get; set; }

        //list of skills
        public List<Skill> SkillList { get; set; }
        //list of job type
        //public List<JobType> JobTypeList { get; set; }

        protected override void SetVars()
        {
            //get login obj
            //get ind obj
            var q = SqlUtilities.QueryMultiple<Login, Ind>(ConstUtils.SP_GetLoginAndInd, new { LoginID = Identity.LoginID });
            Login = ((IEnumerable<Login>)q.Dequeue()).FirstOrDefault();
            Ind = ((IEnumerable<Ind>)q.Dequeue()).FirstOrDefault();

            AvatarUrl = ImageUtils.GetAvatarRelativeUrl(AvatarType.IndAvatar, Identity.AccountID, AvatarSizeEnum.Avatar_80x80, Ind.AvatarFileExtension);

            //skill list
            SkillList = DataUtils.GetSkillListByID(Identity.AccountID);
            //JobTypeList = DataUtils.GetList<JobType>(ConstUtils.SP_GetIndJobTypeList, new { IndID = Identity.AccountID });
        }
    }
}